package com.dstz.crm.core.manager.impl;

import java.util.Date;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.dstz.base.manager.impl.BaseManager;
import com.dstz.crm.core.dao.CustomerShareDao;
import com.dstz.crm.core.manager.CustomerShareManager;
import com.dstz.crm.core.model.CustomerShare;
import com.dstz.sys.util.ContextUtil;
/**
 * 案例 Manager处理实现类
 * @author aschs
 * @email aschs@qq.com
 * @time 2018-08-24 18:06:04
 */
@Service("customerShareManager")
public class CustomerShareManagerImpl extends BaseManager<String, CustomerShare> implements CustomerShareManager{
	@Resource
	CustomerShareDao customerShareDao;

	@Override
	public void customerShare(String customerIds, String userIds) {
		String[] customerIdArr = customerIds.split(",");
		
		customerShareDao.removeBycustomerIds(customerIdArr);
        String[] userIdArr = userIds.split(",");
        for (String customerId : customerIdArr) {
        	for (String userId : userIdArr) {
                if ("0".equals(userId)) {
                	continue;
                }
                CustomerShare customerShare=new CustomerShare();
                customerShare.setCreateBy(ContextUtil.getCurrentUserId());
                customerShare.setCreateTime(new Date());
                customerShare.setCustomerId(customerId);
                customerShare.setShareUserId(userId);
                customerShare.setType("0");
                customerShareDao.create(customerShare);
            }
		}
    }
	
	
}
